var http = createRequestObject();
var field = '';
var title='';


function createRequestObject() {
        var ajax = null;
        if (window.XMLHttpRequest) {
                try {
                        ajax = new XMLHttpRequest();
                }
                catch(e) {}
        }
        else if (window.ActiveXObject) {
                try {
                        ajax = new ActiveXObject("Msxm12.XMLHTTP");
                }
                catch (e){
                        try{
                                ajax = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (e) {}
                }
        }
        return ajax;
}


function check_title(obj) {
	try {

		title=document.getElementById("title").value;
		s_type = document.getElementById("catalog");
		catid = s_type.options[s_type.selectedIndex].value;
		document.getElementById("show_ch_"+obj).innerHTML = "Loading...";
		document.getElementById("show_ch_"+obj).style.display = "block";
		http.open('POST',  '_ajax.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = function() {
			if((http.readyState == 4)&&(http.status == 200)){
				document.getElementById("show_ch_"+obj).innerHTML = http.responseText;
			}
		}
	http.send('type='+obj+'&title='+title+'&catid='+catid);

	}
	catch(e){}
	finally{}
	return false;
}

function check_epi() {
	try {
		s_type = document.getElementById("m_movie");
		movie_id = s_type.options[s_type.selectedIndex].value;
		document.getElementById("show_num_epi").innerHTML = "Loading...";
		document.getElementById("show_num_epi").style.display = "block";
		http.open('POST',  '_ajax.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = function() {
			if((http.readyState == 4)&&(http.status == 200)){
				document.getElementById("show_num_epi").innerHTML = http.responseText;
			}
		}
	http.send('movie_id='+movie_id);

	}
	catch(e){}
	finally{}
	return false;
}

function create_form_multimedia() {
	try {
		s_type = document.getElementById("multimedia_type");
		type_multi = s_type.options[s_type.selectedIndex].value;
			document.getElementById("show_result").innerHTML = "Loading...";
			document.getElementById("show_result").style.display = "block";
			http.open('POST',  '_multimedia.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = function() {
				if((http.readyState == 4)&&(http.status == 200)){
					document.getElementById("show_result").innerHTML = http.responseText;
				}
			}
			http.send('type_multi='+type_multi);
		

	}
	catch(e){}
	finally{}
	return false;
}

function search_multi() {
	try {
		key_search = encodeURIComponent(document.getElementById("key_search").value);
		multitype = encodeURIComponent(document.getElementById("multitype").value);
		document.getElementById("show_result_search").style.display  = "block";
		document.getElementById("show_result_search").innerHTML = "Loading...";
		http.open('POST',  'index.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = function() {
			if((http.readyState == 4)&&(http.status == 200)){
				document.getElementById("show_result_search").innerHTML = http.responseText;
			}
		}
	http.send('key_search='+key_search+'&multitype='+multitype);

	}
	catch(e){}
	finally{}
	return false;
}

function showhide(id,hide) {

	var ie45,ns6,ns4,dom;
if (navigator.appName=="Microsoft Internet Explorer") ie45=parseInt(navigator.appVersion)>=4;
else if (navigator.appName=="Netscape"){  ns6=parseInt(navigator.appVersion)>=5;  ns4=parseInt(navigator.appVersion)<5;}
dom=ie45 || ns6;

		 el = document.all ? document.all[id] :   dom ? document.getElementById(id) :   document.layers[id];
		 els = dom ? el.style : el;
		 html_els = 'button_'+id;
		 if (dom){
			 if (els.display == "none") {
				 els.display = "";
				 document.getElementById(html_els).innerHTML='[-]';
			 } else {
				 els.display = "none";
			   document.getElementById(html_els).innerHTML='[+]';
			 }
		 } else if (ns4){
					if (els.display == "show") {
						els.display = "hide";
					  document.getElementById(html_els).innerHTML='[+]';
					} else {
						els.display = "show";
						document.getElementById(html_els).innerHTML='[-]';
					}
		  }
}
